package com.wwy.arithmetic.newsuanfa;

/**
 * @author 王伟羽
 * @program: arithmetictest
 * @description: 对称二叉树
 * @create: 2025/04/07
 */

public class Duichengerchashu {

    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return judge(root.left,root.right);
    }
    static boolean judge(TreeNode left,TreeNode right){
        if(left==null && right ==null){
            return true;
        }if(left==null||right==null){
            return false;
        }if(left.val!=right.val){
            return false;
        }
        return judge(left.left,right.right)&&judge(left.right,right.left);
    }
}
